package com.minshuu.portlets.demo.lrtut01;
import com.liferay.portal.kernel.util.ParamUtil;
import javax.portlet.GenericPortlet;
import javax.portlet.ActionRequest;
import javax.portlet.RenderRequest;
import javax.portlet.ActionResponse;
import javax.portlet.RenderResponse;
import javax.portlet.PortletException;
import java.io.IOException;
import javax.portlet.PortletRequestDispatcher;

/**
 * LiferayTutorialOne Portlet Class
 */
public class LiferayTutorialOne extends GenericPortlet {

    public void processAction(ActionRequest request, ActionResponse response) throws PortletException,IOException {
        if(ParamUtil.getString(request, "DoSearch", null)==null){
            //Add the logic for searching . .  .
            String searchTerm = ParamUtil.getString(request, "SearchTerm", null);
            response.setRenderParameter("searchResult", "Search results for the term - " + searchTerm);
        }

    }
    
    public void doView(RenderRequest request,RenderResponse response) throws PortletException,IOException {
        response.setContentType("text/html");        
        PortletRequestDispatcher dispatcher =
        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/LiferayTutorialOne_view.jsp");
        dispatcher.include(request, response);
    }
    public void doEdit(RenderRequest request,RenderResponse response) throws PortletException,IOException {
            response.setContentType("text/html");        
        PortletRequestDispatcher dispatcher =
        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/LiferayTutorialOne_edit.jsp");
        dispatcher.include(request, response);
    }
    public void doHelp(RenderRequest request, RenderResponse response) throws PortletException,IOException {

        response.setContentType("text/html");        
        PortletRequestDispatcher dispatcher =
        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/LiferayTutorialOne_help.jsp");
        dispatcher.include(request, response);
    }
}